/****** Object:  Stored Procedure dbo.spr_UpdateDBCarsByPK  ******/

 use [TourIS]
 GO

 if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[spr_UpdateDBCarsByPK]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 drop procedure [dbo].[spr_UpdateDBCarsByPK]
 GO

 SET QUOTED_IDENTIFIER OFF
 GO
 SET ANSI_NULLS OFF
 GO

 CREATE  PROCEDURE [dbo].[spr_UpdateDBCarsByPK]
 (
	@carid int,
	@compid int,
	@details varchar(80),
	@garagevisitreading varchar(15),
	@is3rdparty bit,
	@isactive bit,
	@isauto bit,
	@lastgaragevisit smalldatetime,
	@lastoilchecked smalldatetime,
	@lasttyrechange smalldatetime,
	@make varchar(50),
	@model varchar(50),
	@oilchangereading varchar(15),
	@purchasedate smalldatetime,
	@regno varchar(20),
	@tyrechangereading varchar(15)
 )

 AS

 BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	UPDATE [Cars]
	SET
		[CarId] = @carid,
		[CompId] = @compid,
		[Details] = @details,
		[GarageVisitReading] = @garagevisitreading,
		[Is3rdParty] = @is3rdparty,
		[IsActive] = @isactive,
		[IsAuto] = @isauto,
		[LastGarageVisit] = @lastgaragevisit,
		[LastOilChecked] = @lastoilchecked,
		[LastTyreChange] = @lasttyrechange,
		[Make] = @make,
		[Model] = @model,
		[OilChangeReading] = @oilchangereading,
		[PurchaseDate] = @purchasedate,
		[RegNo] = @regno,
		[TyreChangeReading] = @tyrechangereading

	WHERE
	[CarId] = @carid
	AND [CompId] = @compid


	SET @Err = @@Error
	RETURN @Err
 END

 SET QUOTED_IDENTIFIER OFF
 GO
 SET ANSI_NULLS ON
 GO

